package com.luo.two;
/**
 *
 *可选参数比较多,考虑构造器
 *
 */
public class NutritionFacts
{
	private final int fat ;
	
	private final int weight;
	
	private final int calories;///可选

	
	
	public NutritionFacts(Builder bud)
	{
		this.fat = bud.fat;
		this.calories = bud.calories;
		this.weight = bud.weight;		
	}
	
	public String toString()
	{
		return this.fat+"---"+this.calories+"---"+this.weight;
	}
	
	
	/**
	 * 
	 */
	public static class Builder{
		
		private  int fat ;
		
		private  int weight;
		
		private  int calories;///可选
		
		
		public Builder(int fat,int weight)
		{
			this.fat = fat;
			this.weight = weight;
		}
		
		/**
		 * 
		 *@param car
		 *@return
		 */
		public Builder setCalories(int car){
			this.calories = car;
			return this;
		}
		
		/**
		 * 
		 *@return
		 */
		public NutritionFacts Build(){
		    return new NutritionFacts(this);
		}
	}
	
	
	public static void main(String[] args)
	{
//		NutritionFacts  nuf = new Builder(10, 20).Build();
		NutritionFacts  nuf = new Builder(10, 20).setCalories(1000).Build();
		System.out.println(nuf);
	}
}
